package com.demo.smart;

import org.smartboot.socket.MessageProcessor;
import org.smartboot.socket.transport.AioQuickClient;
import org.smartboot.socket.transport.AioSession;
import org.smartboot.socket.transport.WriteBuffer;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class Client {
    public static void main(String[] args) throws IOException {
        MessageProcessor<String> processor = (session, msg) -> System.out.println("receive from server: " + msg);
        AioQuickClient client = new AioQuickClient("127.0.0.1", 9695, new Server.StringProtocol(), processor);
        AioSession session = client.start();
        WriteBuffer writeBuffer = session.writeBuffer();
        String t1="你好,明天";
        byte[] data1 = t1.getBytes(StandardCharsets.UTF_8);
        writeBuffer.write(data1);
        writeBuffer.flush();
    }
}
